<style>
.ncap-account-container-list { font-size: 0; *word-spacing:-1px/*IE6銆�7*/;
vertical-align: top; display: inline-block; *display: inline/*IE7*/;
width: 80%; padding-left: 1%; *zoom: 1;
}
.ncap-account-container-list li { font-size: 13px; line-height: 20px; color: #999; vertical-align: top; letter-spacing: normal; word-spacing: normal; display: inline-block; *display: inline/*IE7*/;
padding-right: 30px; height: 25px; margin-bottom: 5px; *zoom: 1;
}
.checkbox {
    display: unset;
}
.lab{
	position:relative;
	top:-5px;
	left: 5px;
	color: #000000;
}
</style>
<form method="post" action="/oss/?r=server/doEdit">
    <{include file='../common_params.tpl'}>
    <input type="hidden" name="id" value="<{$info.id}>" />

    <div class="box box-black">
        <div class="box-body">
            <table class="table table-bordered">
                <colgroup>
                    <col style="width: 20%;"></col>
                    <col style="width: 80%;"></col>
                </colgroup>
                
                <tr>
                    <th class="th-label">所属专服</th>
                    <td>
                        <select class="form-control inline" name="special_id" id="special_id" disabled="disabled">
                        	<{foreach from=$specialList item=item key=key}>
                        		<option value="<{$key}>" <{if $info.special_id == $key }>selected<{/if}> ><{$item}></option>
                        	<{/foreach}>
                        </select>
                        <input type="hidden" name="old_special_id" value="<{$info.special_id}>" />
                    </td>
                </tr>
                
                <tr>
                    <th class="th-label">渠道</th>
                    <input type="hidden" value="<{$channes}>" name="old_channel" />
                    <td>
                        <div>
                        	<h5>
								<label><{$item.channel_name}></label>
								<input id="cls_full" type="checkbox">
								<label>全部</label>
							</h5>
                        	
                        	<ul class="ncap-account-container-list" id="channel_list">
                        		    <!--<li>
                        		    	<font color="red">请先选择专服</font>
                        		    </li>-->
							</ul>
                        </div>
                    </td>
                </tr>

                <!--<tr>
                    <th class="th-label-s">服务器状态</th>
                    <td>
                        <{foreach from=$statusList item=item key=key}>
                        <label><input type="radio" name="status" <{if $key == $info.status}>checked<{/if}> value="<{$key}>" /><{$item}></label>
                        <{/foreach}>
                    </td>
                </tr>-->
                
                
<!--
                <tr>
                    <th class="th-label-s">服务器类型</th>
                    <td>
                        <{foreach from=$serverTypeList item=item key=key}>
                        <label><input type="radio" name="server_type" <{if $key == $info.server_type}>checked<{/if}> value="<{$key}>" /><{$item}></label>
                        <{/foreach}>
                    </td>
                </tr>
-->
                <tr>
                    <th class="th-label">服务器名称</th>
                    <td>
                        <input type="text" name="server_name" class="form-control inline" value="<{$info.server_name}>" placeholder="" />
                    </td>
                </tr>
                
                <tr>
                    <th class="th-label">开发ID</th>
                    <td>
                        <input type="text" name="develop_id" class="form-control inline" value="<{$info.develop_id}>"  placeholder="" />
                    </td>
                </tr>
                
                <tr>
                    <th class="th-label">游戏结点名</th>
                    <td>
                        <input type="text" name="name" class="form-control inline" value="<{$info.name}>" readonly="readonly" placeholder="" />
                    </td>
                </tr>
                
                <tr>
                    <th class="th-label">表现状态</th>
                    <td>
                        <select id="sel-end-type" class="form-control inline" name="show_status" >
                        	<{foreach from=$showStatusList item=item key=key}>
                            <option <{if $key == $info.show_status}>selected<{/if}> value="<{$key}>"><{$item}></option>
                            <{/foreach}>
                        </select>
                    </td>
                </tr>
                
                <!--<tr>
                    <th class="th-label">漂浮窗状态</th>
                    <td>
                        <select id="sel-end-type" class="form-control inline" name="float_status" value="<{$info.float_status}>">
                            <option value="1">状态1</option>
                            <option value="2">状态2</option>
                        </select>
                    </td>
                </tr>-->

                <tr>
                    <th class="th-label">服务器ID</th>
                    <td>
                        <input type="number" name="server_num" class="form-control inline" value="<{$info.server_num}>" placeholder="" />
                    </td>
                </tr>
                
                <tr>
                    <th class="th-label">排序</th>
                    <td>
                        <input type="text" name="sort_num" class="form-control inline" value="<{$info.sort_num}>" placeholder="" />
                    </td>
                </tr>


                <tr>
                    <th class="th-label">服务器IP</th>
                    <td>
                        <input type="text" name="ip" class="form-control inline" value="<{$info.ip}>" placeholder="IP" />
                        <input type="text" name="port" size="8" class="form-control inline" value="<{$info.port}>" placeholder="端口" />
                    </td>
                </tr>

                <tr>
                    <th class="th-label">GM API接口地址</th>
                    <td>
                        <input type="text" name="oss_api" class="form-control" value="<{$info.oss_api}>" placeholder="提供GM API调用的接口的地址,如http://119.29.240.201:6027/gm/" />
                    </td>
                </tr>
                <tr>
                    <th class="th-label">服务器日志地址</th>
                    <td>
                        <input type="text" name="log_server" class="form-control" value="<{$info.log_server}>" placeholder="提供日志查询的机器,如123.206.49.53" />
                    </td>
                </tr>
                
                <tr>
                    <th class="th-label">服标记</th>
                    <td>
                        <select class="form-control inline" name="check_flag">
                        	<{foreach from=$checkFlagList item=item key=key}>
                        		<option value="<{$key}>" <{if $info.check_flag == $key }>selected<{/if}> ><{$item}></option>
                        	<{/foreach}>
                        </select>
                    </td>
                </tr>
                
                <tr>
                    <th class="th-label">合服标记</th>
                    <td>
                        <select class="form-control inline" name="hefu_flag">
                        	<{foreach from=$hefuFlagList item=item key=key}>
                        		<option value="<{$key}>" <{if $info.hefu_flag == $key }>selected<{/if}> ><{$item}></option>
                        	<{/foreach}>
                        </select>
                    </td>
                </tr>
<!--
                <tr>
                    <th class="th-label">CDN地址</th>
                    <td>
                        <input type="text" name="cdn_url" class="form-control" value="<{$info.cdn_url}>" />
                    </td>
                </tr>

                <tr>
                    <th class="th-label">Client地址</th>
                    <td>
                        <input type="text" name="client_url" class="form-control" value="<{$info.client_url}>" />
                    </td>
                </tr>
-->
                <tr>
                    <th class="th-label">开服时间</th>
                    <td><input type="text" name="open_time" value="<{$info.open_time}>" class="form-control inline time" /></td>
                </tr>

                <tr>
                    <th class="th-label">合服时间</th>
                    <td>
                        <input type="text" name="union_time" value="<{$info.union_time}>" class="form-control inline time" />
                        <span class="description">无合服则留空</span>
                    </td>
                </tr>

                <tr>
                    <th class="th-label">合到哪个服</th>
                    <td>
                        <input type="text" name="union_server" value="<{$info.union_to}>" class="form-control inline" />
                        <span class="description">合服到哪里，填开发id.没合服则留空.</span>
                    </td>
                </tr>

            </table>
        </div>

        <div class="box-footer">
            <a href="<{$backUrl}>" class="btn btn-default">返回</a>
            <button type="submit" name="sub" class="btn btn-default pull-right">保存</button>
            <input type="hidden" name="page" value="<{$page}>" />
        </div>
    </div>
</form>

<script>
    $(function(){
        $(".time").datetimepicker({
            format: 'yyyy-mm-dd hh:ii:00',
        });
        
        var channes = '<{$channes}>';
        var old_special_id = <{$info.special_id}>;
        var channelList = channes.split(",");
        $("#special_id").change(function(){
        	$('#cls_full').iCheck('uncheck');
        	var g = $('input[name="g"]').val();
	        var url = '?r=specialServer/getChannel&g='+g;
	        var special_id = $(this).val();
	        if(special_id == ''){
	        	var html = '<li><font color="red">请先选择专服</font></li>';
	        	$("#channel_list").html(html);
	        	return false;
	        }
            $.ajax({
    	        type : 'POST',
    	        url : url,
		        data : {'special_id':special_id},
		        dataType :'JSON',
		        success : function(res){
			        if(res.status == 1){	
			        	var list = res.data;
			        	var html = '';
			        	for (var i=0;i<list.length;i++){
			        		var ch = '';
			        		if(old_special_id == special_id && channelList.includes(list[i]['id'])){
			        			ch = 'checked';
			        		}
			        		html += '<li><input class="checkbox" '+ch+' name="channel_id[]" value="'+list[i]['id']+'" type="checkbox"><span class="lab">'+list[i]['channel_name']+'</span></li>'
			        	}
			        	$("#channel_list").html(html);
			        }else{
			        	layer.msg(res.msg, {icon: 2});
			        }
		        }
	        });
        }).change();
        
        
        $('#cls_full').on('ifChecked', function(event){
   	        $(':checkbox').iCheck('check');
        });
   
        $('#cls_full').on('ifUnchecked', function(event){
   	        $(':checkbox[name="channel_id[]"]').iCheck('uncheck');
        });
        
        
        $('button[name="sub"]').click(function(){
        	$('select[name="special_id"]').removeAttr("disabled"); 
        	
        	var special_id = $('select[name="special_id"]').val();
        	if(special_id == ''){
        		layer.alert('请选择专服', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var arr = new Array();
            $("input[name='channel_id[]']:checkbox[checked]").each(function(i){
                arr[i] = $(this).val();
            });
            var channel = arr.join(",");
            if(channel == ''){
        	    layer.msg('请选择渠道', {icon: 2,time: 2000});
        	    return false;
            }
        	
        	var server_name = $('input[name="server_name"]').val();
        	if(server_name == ''){
        		layer.alert('请填写服务器名称', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var develop_id = $('input[name="develop_id"]').val();
        	if(develop_id == ''){
        		layer.alert('请填写开发ID', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var name = $('input[name="name"]').val();
        	if(name == ''){
        		layer.alert('请填写游戏结点名', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var show_status = $('select[name="show_status"]').val();
        	if(show_status == ''){
        		layer.alert('请选择表现状态', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var sort_num = $('input[name="sort_num"]').val();
        	if(sort_num == ''){
        		layer.alert('请填写排序', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
//      	var float_status = $('select[name="float_status"]').val();
//      	if(float_status == ''){
//      		layer.alert('请选择漂浮窗状态', {icon: 2, skin: 'layui-layer-molv'});
//          	return false;
//      	}
        	
        	var ip = $('input[name="ip"]').val();
        	if(ip == ''){
        		layer.alert('请填写IP地址', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var port = $('input[name="port"]').val();
        	if(port == ''){
        		layer.alert('请填写端口号', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var open_time = $('input[name="open_time"]').val();
        	if(open_time == ''){
        		layer.alert('请填写开服时间', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        });

        
    });
</script>